﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace InnovTech.Wpf.Mvvm
{
    public static class ViewModelExt
    {
        public static void RaisePropertyChanged(this IViewModel target, [CallerMemberName] string propName = null)
        {
            if (propName == null) return;
            ViewModelHelper.RaisePropertyChanged(target, propName);
        }

        /// <summary>
        /// Raises this object's PropertyChanged event.
        /// </summary>
        /// <typeparam name="T">The type of the property that has a new value</typeparam>
        /// <param name="propertyExpression">A Lambda expression representing the property that has a new value.</param>
        [SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Justification = "Method used to raise an event")]
        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Cannot change the signature")]
        public static void RaisePropertyChanged<T>(this IViewModel target, Expression<Func<T>> propertyExpression)
        {
            ViewModelHelper.RaisePropertyChanged(target, propertyExpression);
        }
    }
}
